package com.learn.security.modules.security.handler;

import com.learn.security.modules.security.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author lee
 */
@Slf4j
@Component
public class JCLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) {
        LoginUser user = (LoginUser) authentication.getPrincipal();
        String mobile = user.getUserDto().getMobile();
        log.info("mobile: {}  is offline now", mobile);

    }
}
